package cn.schoolwow.util.test.module.check.instance.flow;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import cn.schoolwow.util.domain.check.instance.CheckInstance;
import cn.schoolwow.util.test.module.check.common.domain.AddProject;

public class CheckAddProjectProcessFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        AddProject addProject = (AddProject) flowContext.checkData("addProject");

        CheckInstance.newCheck()
                .notNullCheck(addProject.name, "项目名称")
                .notNullCheck(addProject.creator, "项目创建人")
                .notNullCheck(addProject.departmentId, "项目所属部门")
                .notNullCheck(addProject.projectTemplateId, "项目模板")
                .notNullAnyCheck(new Long[]{addProject.departmentId,addProject.projectTemplateId}, "项目所属部门和项目模板")
                .notEmptyCheck(addProject.timeNodeList, "项目时间节点")
                .isTrueCheck(addProject.timeNodeList.size()==5, "项目时间节点个数不正确")
                .fieldValueCheck(addProject.departmentId, 1L, "部门id")
                .fieldValueCheck(addProject.projectTemplateId, 2L, "模板id")
                .fieldValueCheck(addProject.creator, 3L, "创建人")
                .fieldValueCheck(addProject.name, "测试项目名称", "项目名称");
    }

    @Override
    public String name() {
        return "检查新增项目实例-新增项目";
    }
}
